using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace Pub.Controls
{
    public class Config
    {
        private bool enabled = true;
        public bool Enabled { get { return enabled; } set { enabled = value; } }


        private UpdateFileList updateFileList = new UpdateFileList();
        public UpdateFileList UpdateFileList
        {
            get { return updateFileList; }
            set { updateFileList = value; }
        }

        public static Config LoadConfig(string file)
        {
            Config config =new Config();
            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(Config));
                StreamReader sr = new StreamReader(file);
                config = xs.Deserialize(sr) as Config;
                sr.Close();
            }
            catch (Exception e)
            {
                AuTools.WriteTxt("LoadConfig:" + e.Message.ToString());
            }
            return config;
        }



        public void SaveConfigFile(string file)
        {
            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(Config));
                StreamWriter sw = new StreamWriter(file);
                xs.Serialize(sw, this);
                sw.Close();
            }
            catch (Exception e)
            {
                AuTools.WriteTxt("SaveConfigFile:" + e.Message.ToString());
            }
        }


    }

    public class UpdateFileList : List<LocalFile>
    {
    }

}
